import electron from 'vite-plugin-electron';
import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import pac from './package.json'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
      // 默认最新vite-plugin-electron, 如果插件报错, 具体请看 https://github.com/electron-vite/vite-plugin-electron
      electron({
        entry: 'electron/main.ts',
        onstart: options => {
          // Start Electron App
          options.startup(['.', '--no-sandbox'])
        },
        vite: {
          build: {
            rollupOptions: {
              // Here are some C/C++ plugins that can't be built properly.
              external: Object.keys(pac.dependencies),
            },
          },
        }
      }),
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  }
})
